package com.neusoft.his.sys.util;

import java.util.Collections;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

public class MyGenerator {
	private static final String URL = "jdbc:mysql://localhost:3306/orcl?serverTimezone=UTC";
	private static final String USERNAME = "root";
	private static final String PASSWORD = "root";
	private static final String PACKAGE_NAME = "com.neusoft.his.sys";
	private static final String AUTHOR_NAME = "段静迪";
	private static final String OUTDIR_JAVA = "D:\\admin\\Home\\yd12\\hiss\\demo\\src\\main\\java";
	private static final String OUTDIR_XML = "D:\\admin\\Home\\yd12\\hiss\\demo\\src\\main\\resources\\mappers";

	public static void main(String[] args) {
		FastAutoGenerator.create(URL, USERNAME, PASSWORD).globalConfig(biConsumer -> {
			biConsumer.author(AUTHOR_NAME).fileOverride().outputDir(OUTDIR_JAVA).disableOpenDir();
		}).packageConfig(biConsumer -> {
			biConsumer.parent(PACKAGE_NAME).entity("entity")
					.pathInfo(Collections.singletonMap(OutputFile.mapperXml, OUTDIR_XML)); // 设置mapperXml生成路径
		}).strategyConfig(builder -> {
			builder.addInclude("emp") // 设置需要生成的表名
					.controllerBuilder() // 这里写controllerBuilder，表示将开始controller配置
					.enableRestStyle();
		}).templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
				.execute();
	}
}
